Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HoltWinters method #606

Merged
merged 2 commits into from
Jun 3, 2016
Merged

Add HoltWinters method #606

merged 2 commits into from
Jun 3, 2016

Conversation

nathanielc
Copy link
Contributor

@nathanielc nathanielc commented Jun 3, 2016

Add Holt Winters InfluxQL function

For example one can now define an alert based off forecasted future values.

The following TICKscript will take the last 30 days of disk usage stats and using holt-winters forecast the next 7 days. If the forecasted value crosses a threshold an alert is triggered.

The result is now Kapacitor will alert you 7 days in advance of a disk filling up. This assumes a slow growth but by changing the vars in the script you could check for shorter growth intervals.

// The interval on which to aggregate the disk usage
var agg_interval = 1d
// The number of `agg_interval`s to forecast into the future
var forecast_count = 7
// The amount of historical data to use for the fit
var history = 30d

// The critical threshold on used_percent
var threshold = 90.0

batch
    |query('''
    SELECT max(used_percent) as used_percent
    FROM "telegraf"."default"."disk"
''')
        .period(history)
        .every(agg_interval)
        .align()
        .groupBy(time(agg_interval), *)
    |holtWinters('used_percent', forecast_count, 0, agg_interval)
        .as('used_percent')
    |max('used_percent')
        .as('used_percent')
    |alert()
         // Trigger alert if the forecasted disk usage is greater than threshold
        .crit(lambda: "used_percent" > threshold)
        .slack()
  • Rebased/mergable
  • Tests pass
  • CHANGELOG.md updated

@nathanielc nathanielc merged commit 5ca3ed9 into master Jun 3, 2016
@nathanielc nathanielc deleted the nc-holt-winters branch June 3, 2016 19:56
@elvarb
Copy link

elvarb commented Aug 31, 2016

Is holtWinters out of the project? it does not seem to be available nor in the documentation except for version 0.10

@nathanielc
Copy link
Contributor Author

@elvarb
Copy link

elvarb commented Aug 31, 2016

Ah, all makes sense now. Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants